<template>
  <div class="potosInfo_container">
    <!-- 头部 -->
    <div class="info_header">
      <h1 class="title">{{this.imageInfo.title}}</h1>
      <p>
        <span>发布时间：{{this.imageInfo.add_time | dateFormat}}</span>
        <span>点击：{{this.imageInfo.click}}次</span>
      </p>
      <hr>
    </div>
    <!-- 内容 -->
    <div class="info_content">
      <img class="preview-img" v-for="(item, index) in list" :src="item.src" height="100" @click="$preview.open(index, list)" :key="item.src">
    </div>
    <!-- 评论子组件 -->
    <cmt-box :id="this.id"></cmt-box>
  </div>
</template>

<script>
import comment from "../subcomments/commentContent.vue";
export default {
    data() {
        return {
            id: this.$route.params.id,
            imageInfo: {},
            list: []
        };
    },
    created() {
        this.getimageInfo();
        this.getthumimages();
    },
    methods: {
        getimageInfo() {
            this.$http.get("api/getimageInfo/" + this.id).then(result => {
                if (result.body.status === 0) {
                    this.imageInfo = result.body.message[0];
                    console.log(this.imageInfo);
                } else {
                    Toast("获取图片详情失败！");
                }
            });
        },
        getthumimages() {
            this.$http.get("api/getthumimages/" + this.id).then(result => {
              if ( result.body.status === 0 ) {
                result.body.message.forEach(item=>{
                  item.w = 600;
                  item.h = 400;
                });
                this.list = result.body.message;
              }
            });
        }
    },
    components: {
        "cmt-box": comment
    }
};
</script>

<style lang="scss">
.potosInfo_container {
    .info_header {
        padding: 0 5px;
        .title {
            font-size: 13px;
            text-align: center;
            margin: 20px 0;
        }
        p {
            font-size: 11px;
            display: flex;
            justify-content: space-between;
        }
    }
    .info_content{
      img {
        margin: 10px;
        box-shadow: 0 0 8px #666;
      }
    } 
}
</style>
